package ferp.core.mode;

import ferp.core.game.Game;
import ferp.core.game.Input;
import ferp.core.game.Settings;
import ferp.core.state.State;
import ferp.core.tutorial.Scenario;

/**
 * User: olegs
 * Date: 28/11/2014 22:03
 */
public class MisereConfirm extends Mode
{
  @Override
  public void mark(Game.Listener listener, Game g)
  {
    listener.markMiserePlay();
  }

  @Override
  protected int getStartingPlayer(Game g)
  {
    // make declarer to be the starting player
    return g.player.declarer;
  }

  @Override
  protected int options(Game.Listener listener, Game g, Settings settings, Input input) throws Game.Error
  {
    g.options.set(Input.Options.MISERE_CONFIRM);

    return State.Result.SHOW_OPTIONS;
  }

  @Override
  protected Scenario.Note getOptionsNote(Game g, Settings settings)
  {
    return g.scenario().getContractingOptionsNote(g.rounds, g.player.current);
  }

  @Override
  protected Act act(Game.Listener listener, Game g, Settings settings, Input input) throws Game.Error
  {
    if (input.undoDrop)
      Dropping.undo(listener, g);
    else
      g.set(Mode.misere);

    return Act.DONE;
  }
}
